#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int my_atoi(const char* str)
{
	int cot = 0;
	int sum = 0;
	int t = 1;
	char* tmp = NULL;
	while (*str == ' ')
	{
		str++;
	}
	while (*str >= '0' && *str <= '9')
	{
		tmp = str;
		cot++;
		str++;
	}
	if (cot > 0)
	{
		while (cot)
		{
			sum = sum + ((*tmp - '0') * t);
			t = t * 10;
			cot--;
			tmp--;
		}
		return sum;
	}
	else
		return 0;
}
int main()
{
	char arr[100] = "   123a4";
	int ret = my_atoi(arr);
	printf("%s\n", arr);
	printf("%d\n", ret);
	return 0;
}